package game;

import players.Player;

public class Cell {

  private final Location location;
  private final Player player;


  public Cell(Cell cell) {
    this(cell, cell.player);
  }
   
  
  public Cell (Cell cell, Player player) {
    this(cell.location, player);
  }


  public Cell (int x, int y, Player player) {
    this.location = new Location(x, y);
    this.player = player;
  }


  public Cell (Location location, Player player) {
    this(location.getX(), location.getY(), player);
  }


  @Override
  public Cell clone() { return new Cell(this); }


  @Override
  public boolean equals(Object other) {
    if (! (other instanceof Cell)) return false;
    return ((Cell)other).getLocation().equals(location) &&
           ((Cell)other).getPlayer().equals(player);
  }


  public Location getLocation() { return location; }


  public Player getPlayer() { return player; }


  public int getX() { return location.getX();	}


  public int getY() { return location.getY(); }


  public boolean isResignation() { return location.isResignation(); }


  public Cell newCellWithNewPlayer(Player newPlayer) {
    return new Cell(location.clone(), newPlayer);
  }


  @Override
  public String toString(){
    return location + "[" + player + "]";
  }


}
